<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center startReading_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub startReading_fd0_0'>
          <view class='flex flex-wrap align-center startReading_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  startReading_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='startReading_fd0_0_c1_c0'>{{article.title}}</text>
          </view>
          <view class='flex flex-wrap align-center justify-end startReading_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center startReading_flex_1">
        <jyf-parser class='startReading_fd1_0' :html="article.content | richTextFormat">
        </jyf-parser>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-wrap align-center justify-center benben-position-layout flex startReading_flex_2">
        <button class='startReading_fd2_0' @tap.stop="handleJumpDiy" data-type="back"
          data-url="1">{{$t('修持完毕')}}</button>

      </view>
      <view :style="{height: '140rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center startReading_flex_3" v-if="current!=total-1"
        @click="nextVideo">
        <button class='startReading_fd3_0'>{{$t('下一章')}}</button>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "article": {
          "title": "",
          "book_title": "",
          "aid": "",
          "content": "",
          "sort": "",
          "create_time": "",
          "is_del": "",
          "book_id": ""
        },
        "id": "",
        articleList: [],
        current: 0,
        total: 0,
        book_id: ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        id,
        book_id
      } = options
      if (id !== undefined) this.id = id
      if (book_id !== undefined) this.book_id = book_id
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getArticleFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      nextVideo() {
        this.current++
        if (this.current < this.total) {
          this.article = this.articleList[this.current]
        } else {

        }
      },
      //获取文章
      async getArticleFunc() {
        //请求方法
        //数据验证

        let dataarticle = await this.$api.post(global.apiUrls.post659b90879b58e, {
          aid: this.id,
          book_id: this.book_id
        });

        if (dataarticle.data.code != 1) {
          this.$message.info(dataarticle.data.msg);
          return
        }
        let infoarticle = dataarticle.data;
        this.articleList = infoarticle.data
        this.total = this.articleList.length
        this.article = this.articleList[0]
        console.log('this.article', this.article)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(247, 243, 237, 1);
    background-size: 100% auto;
  }

  .startReading_flex_0 {
    border-bottom: 1px solid #eee;
    background: rgba(247, 243, 237, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .startReading_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .startReading_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .startReading_fd0_0_c0 {
    width: 120rpx;
  }

  .startReading_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .startReading_flex_1 {
    padding: 25rpx 32rpx 0rpx 32rpx;
  }

  ::v-deep .startReading_fd1_0 {
    width: 100%;
  }

  .startReading_flex_2 {
    background: rgba(235, 228, 217, 1);
    width: 750rpx;
    height: 140rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    background-size: 100% auto;
  }

  .startReading_fd2_0 {
    background: rgba(145, 47, 34, 1);
    border-radius: 44rpx;
    width: 686rpx;
    line-height: 80rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .startReading_flex_3 {
    position: fixed;
    bottom: calc(220rpx + var(--window-bottom));
    right: 49rpx;
  }

  .startReading_fd3_0 {
    background: rgba(152, 112, 64, 1);
    border-radius: 40rpx;
    min-width: 112rpx;
    line-height: 64rpx;
    font-size: 26rpx;
    color: #fff;
  }
</style>
